package com.ys.controller.api.sys;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ys.entity.sys.YsIcon;
import com.ys.service.sys.CommonApiService;
import com.ys.service.sys.YsIconService;
import com.ys.vo.LayuiTableVoJA;
import com.ys.vo.R;

@Controller
@RequestMapping("/api/inter/ysIcon")
public class ApiInterYsIconController {
	
	public static Long MENU_ID = 10195L;
	
	@Autowired
	private CommonApiService<YsIcon> commonApiService;
	@Autowired
	private YsIconService ysIconService;

	@RequiresPermissions("ysIcon:view")
	@RequestMapping("/search")
    @ResponseBody
	public LayuiTableVoJA search(Model model, HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute YsIcon cond
			){
		
		cond.setOrderby("A.Id asc");
		
		return commonApiService.searchLay(cond);
	}
	
	/**
	 * 新增
	 */
	@RequiresPermissions("ysIcon:add")
	@PostMapping("/add")
	@ResponseBody
	public R add(HttpServletRequest request,
			@RequestParam Map<String, Object> params){
		return ysIconService.add(params);
	}
	
	/**
	 * 编辑
	 */
	@RequiresPermissions("ysIcon:edit")
	@PostMapping("/edit")
    @ResponseBody
	public R edit(Model model, HttpServletRequest request, HttpServletResponse response,
			@RequestParam Map<String, Object> params){
		
		return ysIconService.edit(params);
	}
	
	/*
	 * 彻底删除
	 */
	@PostMapping("/deleteTrue")
	@ResponseBody
	public R deleteTrue(HttpServletRequest request, HttpServletResponse response,
			Long id) {
		return ysIconService.deleteTrue(id);
	}
	
}
